package java学习.去哪儿;

/**
 * **************
 * 项目名称: 蓝桥杯-Java学习 <br/>
 * 文件名称:  <br/>
 * 文件描述: 这里添加您的类文件描述，说明当前文件要包含的功能。 <br/>
 * 文件创建：刘世锦Lenovo <br/>
 * 创建时间: 2022/9/7 <br/>
 *
 * @version v1.0 <br/>
 * @update [序号][日期YYYY-MM-DD][更改人姓名][变更描述]<br/>
 * *************
 */
public class 扑克 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 翻牌
     * @param inHand string字符串 一组以单空格间隔的手牌(例如：SA HK H9 D8 C5 S5 H4)
     * @return string字符串
     */



    public static int[] getHcount(char[] chars){
        int huas = 0,nc = 0;
        char s = 'S';
        char h = 'H';
        char c = 'C';
        char d = 'D';
        int sc = 0,hc=0,cc=0,dc=0;
        for (char aChar : chars) {
            if (aChar == s){
                sc++;
            }   if (aChar == h){
                hc++;
            }   if (aChar == c){
                cc++;
            }   if (aChar == d){
                dc++;
            }
        }
        int result = Math.max(sc, Math.max(hc, Math.max(cc, dc)));
        int[] arr = new int[2];
        arr[0] = result;
        arr[1] = nc;
        return arr ;
    }

    public static String showDown (String inHand) {
        int huas = 0,nc = 0;
        String r= "";
        char[] chars = inHand.toCharArray();
        char max = 0,min = 1000;
        for (char aChar : chars) {
            if (aChar>max) max = aChar;
            if (aChar<min) min = aChar;
        }
        int[] arr = getHcount(chars);
        huas = arr[0] ; nc = arr[1];
        if (huas<=2){
            r="YiDui";
        }  if (huas==3){
            r="SanTiao";
        }  if (huas==5){
            r="TongHua";
        }  if (huas==5){
            r="HuangJiaTongHuaShun";
        }  if (huas<=2){
            r="YiDui";
        }  if (huas<=2){
            r="YiDui";
        }  if (huas<=2){
            r="YiDui";
        }  if (huas<=2){
            r="YiDui";
        }

        return r;
    }
}
